package com.allenyuan.renderobject;

import java.util.ArrayList;
import java.util.List;

import com.allenyuan.render.Renderer;

public class RenderPathElement extends RenderObject {
	
	public static final int RENDER_PATH_LINE = 0;
	public static final int RENDER_PATH_BEZIER_2 = 1;
	public static final int RENDER_PATH_BEZIER_3 = 2;
	
	private List<RenderPoint> points = new ArrayList<RenderPoint>();
	private int pathType;
	
	public RenderPathElement(int type) {
		super(RENDER_PATH_ELEMENT);
		this.pathType = type;
	}

	public RenderPathElement(List<RenderPoint> points, int type) {
		super(RENDER_PATH_ELEMENT);
		this.points = points;
		this.pathType = type;
	}

	public int getPathType() {
		return pathType;
	}

	@Override
	public void draw(Renderer r) {
		// TODO Auto-generated method stub
		switch(pathType) {
		case RENDER_PATH_LINE:
			r.drawLine(points.get(0).getX(), points.get(0).getY(),
						points.get(1).getX(), points.get(1).getY());
			break;
		case RENDER_PATH_BEZIER_2:
			
			break;
		case RENDER_PATH_BEZIER_3:
			if (points.size() == 4) {
				r.drawBezier3(points.get(0).getX(), points.get(0).getY(),
								points.get(1).getX(), points.get(1).getY(),
								points.get(2).getX(), points.get(2).getY(),
								points.get(3).getX(), points.get(3).getY());
			}
			break;
		default:
			break;
		}
	}

	@Override
	public void drawProgress(int mouse, RenderPoint point) {
		// TODO Auto-generated method stub
		if (pathType == RENDER_PATH_BEZIER_3 && points.size() <= 4) {
			switch (mouse) {
			case MOUSE_CLICK:
				points.add(point);
			default:
				break;
			}
		}
	}
	
	

}
